package com.ocom.payconfig.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ocom.common.enums.DataSourceEnum;
import com.ocom.common.request.payconfig.SubsidyDataRequest;
import com.ocom.common.vo.payconfig.SubsidyDataVo;
import com.ocom.mysql.aspect.DataSourceAspect;
import com.ocom.payconfig.dao.IDaoSubsidyDataVo;
import com.ocom.payconfig.service.SubsidyDataVoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Slf4j
@Service
public class SubsidyDataVoServiceImpl extends ServiceImpl<IDaoSubsidyDataVo, SubsidyDataVo> implements SubsidyDataVoService {


    @Autowired
    private IDaoSubsidyDataVo iDaoSubsidyDataVo;

    @DataSourceAspect(type = DataSourceEnum.PART_DB,companyId = "comId")
    @Override
    public List<SubsidyDataVo> selectSubsidyData(Long comId, SubsidyDataRequest subsidyDataRequest) {
        PageHelper.startPage(subsidyDataRequest.getPage(),subsidyDataRequest.getSize());
        if (subsidyDataRequest.getDeptIds()!=null){
            String[] arr=subsidyDataRequest.getDeptIds().split(",");
            subsidyDataRequest.setDeptIdList(Arrays.asList(arr));
        }
        return iDaoSubsidyDataVo.SubsidyDataVo(subsidyDataRequest);
    }
}
